package cn.edu.scau.cmi.ningkehua.adapter;

//import application.Student;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class MyController {
	public MyController() {
	}

	@FXML
	private void initialize() {
		System.out.println("初始化完成！");
	}

	@FXML
	private Button button;

	@FXML
	private TextArea area;

	@FXML
	private TextField num;

	@FXML
	private TextField name;

	public Button getButton() {
		return button;
	}

	public void setButton(Button button) {
		this.button = button;
	}

	public TextArea getArea() {
		return area;
	}

	public void setArea(TextArea area) {
		this.area = area;
	}

	public TextField getNum() {
		return num;
	}

	public void setNum(TextField num) {
		this.num = num;
	}

	public TextField getName() {
		return name;
	}

	public void setName(TextField name) {
		this.name = name;
	}

	@FXML
	private void eventAction(ActionEvent event) {
		//area.appendText("666");
		int number=Integer.parseInt(num.getText());
		String stu_name=name.getText();
		Student stu=new Student();
		stu.setName(stu_name);
		stu.setNumber(number);
		ClassAdapter.list_stu.add(stu);
		Target adapter=new ClassAdapter();
		ClassAdapter.list_stu=adapter.sortStudent(ClassAdapter.list_stu);
		area.clear();
		area.appendText("类适配器输出:\n");
		 for(Student s:ClassAdapter.list_stu) {
			 
			 area.appendText(String.valueOf(s.getNumber()));
			 area.appendText(" "+s.getName()+"\n");
		 }
		 
		 ObjectAdapter.students.add(stu);
		 Target adapter2=new ObjectAdapter();
		 adapter2.sortStudent(ObjectAdapter.students);
		 area.appendText("对象适配器输出:\n");
		 for(Integer s:ObjectAdapter.list2) {
			 for(Student s2:ObjectAdapter.students) {
				 if(s==s2.getNumber()) {
					area.appendText(String.valueOf(s));
					area.appendText(" "+s2.getName()+"\n");
					break;
				 }
			 }
			 System.out.println(ObjectAdapter.list2.size());
			 System.out.println(ObjectAdapter.students.size());
			 
			 
			 
			 //area.appendText(String.valueOf(s.getNumber()));
			 //area.appendText(" "+s.getName()+"\n");
		 }

	}

}
